/*    */ package com.zhonglee.register;
/*    */ 
/*    */ import java.io.File;
/*    */ import java.io.FileInputStream;
/*    */ import java.io.FileOutputStream;
/*    */ import java.io.IOException;
/*    */ import java.util.Properties;
/*    */ import java.util.logging.Level;
/*    */ import java.util.logging.Logger;
/*    */ 
/*    */ public class RegisterPropertiesUtils
/*    */ {
/* 21 */   private String PROPERTIES_FILE_PATH = "";
/*    */   private static final String PROPERTIES_FILE = "register.properties";
/*    */   private static final String SERIAL_CODE_KEY = "serial_code_key";
/*    */ 
/*    */   public static RegisterPropertiesUtils getInstance(String propertiesFilePath)
/*    */   {
/* 26 */     RegisterPropertiesUtils registerPropertiesUtils = new RegisterPropertiesUtils();
/* 27 */     registerPropertiesUtils.setPropertiesFilePath(propertiesFilePath);
/* 28 */     return registerPropertiesUtils;
/*    */   }
/*    */ 
/*    */   public String getPropertiesFilePath() {
/* 32 */     return this.PROPERTIES_FILE_PATH;
/*    */   }
/*    */ 
/*    */   public void setPropertiesFilePath(String PROPERTIES_FILE_PATH) {
/* 36 */     this.PROPERTIES_FILE_PATH = PROPERTIES_FILE_PATH;
/*    */   }
/*    */ 
/*    */   public String getSerialCode() {
/* 40 */     Properties p = getRegisterProperties();
/* 41 */     return p.getProperty("serial_code_key");
/*    */   }
/*    */ 
/*    */   public void setSerialCode(String serialCode)
/*    */   {
/* 46 */     Properties p = getRegisterProperties();
/* 47 */     p.setProperty("serial_code_key", serialCode);
/*    */     try {
/* 49 */       p.store(new FileOutputStream(getFile()), serialCode);
/*    */     } catch (IOException ex) {
/* 51 */       Logger.getLogger(RegisterPropertiesUtils.class.getName()).log(Level.SEVERE, null, ex);
/*    */     }
/*    */   }
/*    */ 
/*    */   private Properties getRegisterProperties()
/*    */   {
/* 57 */     File file = getFile();
/* 58 */     Properties p = new Properties();
/*    */     try {
/* 60 */       p.load(new FileInputStream(file));
/*    */     } catch (IOException ex) {
/* 62 */       Logger.getLogger(RegisterPropertiesUtils.class.getName()).log(Level.SEVERE, null, ex);
/*    */     }
/* 64 */     return p;
/*    */   }
/*    */ 
/*    */   private File getFile() {
/* 68 */     String fileFullName = "register.properties";
/* 69 */     if ((this.PROPERTIES_FILE_PATH != null) || (this.PROPERTIES_FILE_PATH.trim().length() != 0)) {
/* 70 */       fileFullName = this.PROPERTIES_FILE_PATH + "register.properties";
/*    */     }
/* 72 */     File file = new File(fileFullName);
/* 73 */     if (!file.exists()) {
/*    */       try {
/* 75 */         file.createNewFile();
/*    */       } catch (IOException ex) {
/* 77 */         Logger.getLogger(RegisterPropertiesUtils.class.getName()).log(Level.SEVERE, null, ex);
/*    */       }
/*    */     }
/* 80 */     return file;
/*    */   }
/*    */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.zhonglee.register.RegisterPropertiesUtils
 * JD-Core Version:    0.6.2
 */